//
//  CustomeOverView.m
//  U9WatchGame
//
//  Created by 高博昆 on 15/6/19.
//  Copyright (c) 2015年 Jason. All rights reserved.
//

#import "CustomeOverView.h"

@interface CustomeOverView()
@property (nonatomic, strong) NSString *type;
@end

@implementation CustomeOverView
- (instancetype)init{
    if (self = [super init]) {
    }
    return self;
}


-(void)drawRect:(CGRect)rect{
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    
    UIColor *gradientOuter = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.6];
    UIColor *gradientInner = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.4];
    
    // gradients
    NSArray *radialGradientColors = @[(id)gradientInner.CGColor, (id)gradientOuter.CGColor];
    CGFloat radialGradientLocations[] = {0, 0.5, 1};
    CGGradientRef radialGradient = CGGradientCreateWithColors(colorSpace, (__bridge CFArrayRef)radialGradientColors, radialGradientLocations);
    
    // main shape
    UIBezierPath *rectanglePath = [UIBezierPath bezierPathWithRect:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];
    CGContextSaveGState(context);
    [rectanglePath addClip];
    CGContextDrawRadialGradient(context, radialGradient, CGPointMake(rect.origin.x+rect.size.width/2, rect.origin.y+rect.size.height/2), rect.size.width/4, CGPointMake(rect.origin.x+rect.size.width/2, rect.origin.y+rect.size.height/2), rect.size.width, kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
    CGContextRestoreGState(context);
    
    // clean up
    CGGradientRelease(radialGradient);
    CGColorSpaceRelease(colorSpace);
}


@end
